# -*- coding: utf-8 -*-
''' nn.Module '''
import torch
from torch import nn

class Model(nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, x):
        return x + 1

print(Model()(torch.tensor(1.0)))

input = torch.tensor([[1, 2, 0, 3, 1],
                      [0, 1, 2, 3, 1],
                      [1, 2, 1, 0, 0],
                      [5, 2, 3, 1, 1],
                      [2, 1, 0, 1, 1]])

input = torch.reshape(input, (1, 1, 5, 5)) # batch_size, channel, height, width

kernel = torch.tensor([[1, 2, 1],
                       [0, 1, 0],
                       [2, 1, 0]])

kernel = torch.reshape(kernel, (1, 1, 3, 3))

print(nn.functional.conv2d(input, kernel))
print(nn.functional.conv2d(input, kernel, stride=2)) # kernel移动的步长
print(nn.functional.conv2d(input, kernel, padding=1)) # 填充
